﻿using System;
using System.Collections;
using System.Text;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

namespace Livraria
{
    public partial class InserirProduto : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            TextBox_nome.Text = "";

        }

        protected void TextBox_nome_TextChanged(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string nome = TextBox_nome.Text;
            string categoria = DropDownList1.SelectedItem.Value;
            //string sqlinsert="insert into produto ('nome','categoria')"+"values(''"+nome+",''"+categoria+")";
            StringBuilder sql=new StringBuilder();
            sql.Append("INSERT INTO PRODUTO ('NOME','CATEGORIA' ");
            sql.Append("values('"+nome+"','"+categoria+"')");
             
            SqlConnection sqlcon = new SqlConnection(@"Data Source= srv-acd-sql;Initial Catalog=bdAsp_andre;Integrated Security=True");
            SqlCommand cmd = new SqlCommand(sql.ToString(), sqlcon);
            cmd.Connection.Open();
            cmd.ExecuteNonQuery();
            cmd.Connection.Close();

            
        }
    }
}
